package com.example.monitordemo.constant;

import static com.example.monitordemo.config.MonitorConfig.TOMCAT_INSTANCE;
import static com.example.monitordemo.config.MonitorConfig.TOMCAT_JOB;

public interface TomcatConstant {



    /**
     * tomcat信息
     */
    String SERVER_INFO = "tomcat_serverinfo{job=\""+TOMCAT_JOB+"\", instance=\""+TOMCAT_INSTANCE+"\"}";

    /**
     *  最大线程数
     */
    String MAX_THREADS = "tomcat_threadpool_maxthreads{job=\""+TOMCAT_JOB+"\", instance=\""+TOMCAT_INSTANCE+"\", protocol=\"http-nio\"}";

    /**
     * 最小空闲线程数。
     */
    String MIN_SPARE_THREADS = "tomcat_threadpool_minsparethreads{job=\""+TOMCAT_JOB+"\", instance=\""+TOMCAT_INSTANCE+"\", protocol=\"http-nio\"}";

    /**
     * 接受线程数
     */
    String ACCEPT_THREAD_COUNT = "tomcat_threadpool_acceptcount{job=\""+TOMCAT_JOB+"\", instance=\""+TOMCAT_INSTANCE+"\", protocol=\"http-nio\"}";

    /**
     * 接受器线程数
     */
    String ACCEPTOR_THREAD_COUNT = "tomcat_threadpool_acceptorthreadcount{job=\""+TOMCAT_JOB+"\", instance=\""+TOMCAT_INSTANCE+"\", protocol=\"http-nio\"}";

    /**
     * 轮询器线程数量
     */
    String POLLER_THREAD_COUNT = "tomcat_threadpool_pollerthreadcount{job=\""+TOMCAT_JOB+"\", instance=\""+TOMCAT_INSTANCE+"\", protocol=\"http-nio\"}";

    /**
     * 流量接收
     */
    String TRAFFIC_RECV = "increase(tomcat_bytesreceived_total{job=\""+TOMCAT_JOB+"\", instance=\""+TOMCAT_INSTANCE+"\", protocol=\"http-nio\"}[1m])";

    /**
     * 流量发送
     */
    String TRAFFIC_SEND = "increase(tomcat_bytessent_total{job=\""+TOMCAT_JOB+"\", instance=\""+TOMCAT_INSTANCE+"\", protocol=\"http-nio\"}[1m])";

    /**
     * Inspect: 请求数
     */
    String REQUEST_COUNT = "increase(tomcat_requestcount_total{job=\""+TOMCAT_JOB+"\", instance=\""+TOMCAT_INSTANCE+"\", protocol=\"http-nio\"}[1m])";

    /**
     * Inspect: 错误数
     */
    String ERROR_COUNT = "increase(tomcat_errorcount_total{job=\""+TOMCAT_JOB+"\", instance=\""+TOMCAT_INSTANCE+"\", protocol=\"http-nio\"}[1m])";

    /**
     * 现有线程数 threads
     */
    String CURRENT_THREAD_COUNT = "tomcat_threadpool_currentthreadcount{job=\""+TOMCAT_JOB+"\", instance=\""+TOMCAT_INSTANCE+"\", protocol=\"http-nio\"}";

    /**
     * 现有忙线程数 threads
     */
    String CURRENT_THREAD_BUSY = "tomcat_threadpool_currentthreadsbusy{job=\""+TOMCAT_JOB+"\", instance=\""+TOMCAT_INSTANCE+"\", protocol=\"http-nio\"}";

    /**
     * 线程连接数 threads
     */
    String THREAD_CONNECTION_COUNT = "tomcat_threadpool_connectioncount{job=\""+TOMCAT_JOB+"\", instance=\""+TOMCAT_INSTANCE+"\", protocol=\"http-nio\"}";

    /**
     * 保持连接数 threads
     */
    String KEEP_ALIVE_COUNT = "tomcat_threadpool_keepalivecount{job=\""+TOMCAT_JOB+"\", instance=\""+TOMCAT_INSTANCE+"\", protocol=\"http-nio\"}";

    /**
     * tomcat总会话数 Session count
     */
    String TOMCAT_SESSION_TOTAL = "sum(increase(tomcat_session_sessioncounter_total{job=\""+TOMCAT_JOB+"\", instance=\""+TOMCAT_INSTANCE+"\"}[1m])) by (instance)";

    /**
     * tomcat过期会话数 Session count
     */
    String TOMCAT_EXPIRED_SESSIONS_TOTAL = "sum(increase(tomcat_session_expiredsessions_total{job=\""+TOMCAT_JOB+"\", instance=\""+TOMCAT_INSTANCE+"\"}[1m])) by (instance)";

    /**
     * tomcat拒绝会话数 Session count
     */
    String TOMCAT_REJECTED_SESSIONS_TOTAL = "sum(increase(tomcat_session_rejectedsessions_total{job=\""+TOMCAT_JOB+"\", instance=\""+TOMCAT_INSTANCE+"\"}[1m])) by (instance)";

    /**
     * tomcat 现有会话数
     */
    String TOMCAT_CURRENT_SESSION_COUNT = "sum(tomcat_session_sessioncounter_total{job=\""+TOMCAT_JOB+"\", instance=\""+TOMCAT_INSTANCE+"\"} - tomcat_session_expiredsessions_total)";

    /**
     * 前五请求
     */
    String TOP5_REQUEST = "topk(5, increase(tomcat_servlet_requestcount_total{job=\""+TOMCAT_JOB+"\", instance=\""+TOMCAT_INSTANCE+"\"}[1m]))";

    /**
     * 前五错误
     */
    String TOP5_REQUEST_ERROR = "topk(5, increase(tomcat_servlet_errorcount_total{job=\""+TOMCAT_JOB+"\", instance=\""+TOMCAT_INSTANCE+"\"}[1m]))";


    /**
     * 前五平均处理时间。
     */
    String TOP5_PROCESS_TIME = "topk(5, increase(tomcat_servlet_processingtime_total{job=\""+TOMCAT_JOB+"\", instance=\""+TOMCAT_INSTANCE+"\"}[1m]) / increase(tomcat_servlet_requestcount_total{job=\""+TOMCAT_JOB+"\", instance=\""+TOMCAT_INSTANCE+"\"}[1m]))";


}
